<?php

/**
 * Send message/notification for user/pegawai
 * @property integer $id_pegawai
 * @property String $notifikasi
 * @property Integer $status
 * @property String $url
 * @property String $created_date
 * @author aris
 */
class SendMessage {
    
    public  $id_pegawai;
    public  $notifikasi;
    public  $status  = 0;
    public  $url;
    public  $created_date;
    
    /**
     * Send All messages
     * @access public
     * @param Pegawai $pegawai 
     * @param Array $data
     * @return Boolean
     */
    function __construct(Pegawai $pegawai, Array $data) {
        $this->created_date     = date('Y-m-d H:i:s');
        $this->status           = $data['status'];
        $this->notifikasi       = $data['notifikasi'];
        $this->url              = $data['url'];
        $this->id_pegawai       = $pegawai->getPrimaryKey();
        
        $this->sendSms($pegawai, $data);
        $this->sendEmail($pegawai, $data);
        $this->sendNotification($pegawai, $data);
    }
    
    
    /**
     * @param Pegawai $pegawai
     * @param Array $data
     * @return boolean
     */
    public function sendSms(Pegawai $pegawai, Array $data)
    {
        
    }
    
    /**
     * @access  public
     * @param Pegawai $pegawai
     * @param Array $data
     * @return boolean 
     */
    public  function sendEmail(Pegawai $pegawai, Array $data)
    {
        
    }
    
    /**
     * @access  public
     * @param Pegawai $pegawai
     * @param Array $data
     * @return boolean 
     */
    public function sendNotification(Pegawai $pegawai, Array $data)
    {
        $pesanNotifikasi = new PesanNotifikasi;
        $pesanNotifikasi->id_pegawai = $pegawai->getPrimaryKey();
        $pesanNotifikasi->notifikasi = $this->notifikasi;
        $pesanNotifikasi->status     = $this->status;
        $pesanNotifikasi->url        = $this->url;
        $pesanNotifikasi->created_date = $this->created_date;
        
        return $pesanNotifikasi->save(); 
        
    }
}

?>
